var oBtn = document.querySelector("button");
var oSpan = document.querySelector("span");

oBtn.onclick = function () {
  oSpan.style.opacity = 1;
  timer = setInterval(function () {
    oSpan.style.opacity = 0;
    clearInterval(timer);
  }, 3000);
}